package yijy.threeCountry;

/**
 * Created by yijy on 2017/5/31.
 */
public class Stage implements Runnable{

    public static void main(String[] args) {
        new Stage().run();
    }

    @Override
    public void run() {
        TaskFarmerArmy farmerArmy = new TaskFarmerArmy();
        TaskFarmerArmy normalArmy = new TaskFarmerArmy();
        Hero hero = new Hero(normalArmy);

        Thread farmer = new Thread(farmerArmy,"农民军");
        Thread normal = new Thread(normalArmy,"正规军");
        Thread heroThread = new Thread(hero,"Mr.chen");
        heroThread.setPriority(7);
        farmer.start();
        normal.start();
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        heroThread.start();
        if(farmerArmy.blood==0){
            farmerArmy.keeprunning=false;
        }
        if(normalArmy.blood==0){
            normalArmy.keeprunning=false;
        }

        try {
            Thread.sleep(50);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
